$(function () {
    $('#client_lose_datagrid').datagrid({
        fit:true,
        url:'/clientLose/selectAllLose.do',
        pagination:true,
        fitColumns:true,
        toolbar:"#client_lose_toolbar",
        singleSelect:true,
        rownumbers:true,
        columns:[[
            {field:'id',title:'编号',width:100,hidden:true},
            {field:'inputTime',title:'录入时间',width:30},
            {field:'takeUser',title:'当时负责人',width:30,formatter:function (value, row, index) {
                if(row.takeUser != null) {
                    return row.takeUser.username;
                }else{
                    return "<font style='color: red'>当时无负责人</font>";
                }
            }},
            {field:'name',title:'客户名称',width:30},
            {field:'reason',title:'客户流失原因',width:100}
        ]]
    });
});


function query() {
    var name = $("#name").textbox('getValue');
    var takeUser = $("#takeUser").combobox('getValue');
    var beginTime = $("#beginTime").textbox('getValue');
    var endTime = $("#endTime").textbox('getValue');

    $("#client_lose_datagrid").datagrid('load',{
        name:name,
        takeUser_id:takeUser,
        beginTime:beginTime,
        endTime:endTime
    });
}